import config from "config";
import { Sequelize } from "sequelize";
import { myLog } from "../log/log";
const dbLogger = myLog("db");
dbLogger.level = "info";
function log(args: string) {
    dbLogger.info(args);
}

interface IDBconfig {
    dialect: string;
    database: string;
    username: string;
    password: string;
    host: string;
    port: number;
}
const dbConfig = config.get<IDBconfig>("db");

export default new Sequelize({
    dialect: "mysql",
    database: dbConfig.database,
    host: dbConfig.host,
    username: dbConfig.username,
    password: dbConfig.password,
    port: dbConfig.port,
    logging: log
});
